package top.lakakala.service;

import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import top.lakakala.dao.WorkInfoMapper;
import top.lakakala.entity.WorkInfo;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by k3312 on 2017/8/3.
 */
@Service
@Transactional
public class WorkInfoService {
    public static final int INDEX_WORK_INFO_PAGE_SIZE = 5;
    public static final String LEFT_WORK_INFO_INFO = "left";
    public static final String RIGHT_WORK_INFO_INFO = "right";
    @Autowired
    private WorkInfoMapper workInfoMapper;

    public Map<String, List<WorkInfo>> indexWorkInfoList() {
        PageHelper.startPage(1, INDEX_WORK_INFO_PAGE_SIZE);
        List<WorkInfo> leftWorkInfoList = workInfoMapper.selectList();
        PageHelper.startPage(2, INDEX_WORK_INFO_PAGE_SIZE);
        List<WorkInfo> rightWorkInfoList = workInfoMapper.selectList();
        Map<String, List<WorkInfo>> workInfoListMap = new HashMap<>();
        workInfoListMap.put(LEFT_WORK_INFO_INFO, leftWorkInfoList);
        workInfoListMap.put(RIGHT_WORK_INFO_INFO, rightWorkInfoList);
        return workInfoListMap;
    }

}
